<form action="index.php?app=content&ctl=admin_node&act=update" id="nodecatEditor" method="post">
    <{area inject=".mainHead"}>

        <h2 class="head-title"><{t}>文章栏目<{/t}><em class="num">(<{t}>共<{/t}><{$tree_number}><{t}>条<{/t}>)</em></h2>

        <div class="gridlist-action finder-action clearfix">
        	<{assign var=addnodecat value=$___a='添加节点'|t:'content'}>
			<{assign var=editnodesort value=$___b2c="编辑排序"|t:'content'}>
			<{assign var=savenodesort value=$___b2c="保存排序"|t:'content'}>
<{button app="desktop" label=$addnodecat  icon="btn_add.gif" onclick="new Dialog('index.php?app=content&ctl=admin_node&act=add', {title:'{$addnodecat}', height:'470'})" }>
            <{button app="desktop" tmplabel=$savenodesort label=$editnodesort  id="edit-nodecatsort"}> 
 
<{if $tree_number<=500}> <{button app="desktop" label=$___content="展开节点"|t:'content'  id="showCat-handle" icon="btn_unfolded.gif" }> <{button app="desktop" label=$___content="收起节点"|t:'content'  icon="btn_folded.gif" id="hideCat-handle" }><{/if}>
            &nbsp;
        </div>
<div class="Node">
        <div class='gridlist-head mainHead finder-head'>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
	
			<td width="18%"><{t}>节点名称<{/t}></td>
	        <td width="12%" style="text-align:left;">&nbsp;&nbsp;&nbsp;&nbsp;<{t}>节点路径<{/t}></td>
			<td width="8%"><{t}>排序<{/t}></td>
			<td width="45%"><{t}>操作<{/t}></td>
            </tr></table>
        </div>
  </div>
    <{/area}>
    <div class="Node-body">
    <div id="node_tree" class='gridlist catlist'>
		<{foreach from=$list item=item name="item"}>
        <div style="padding:0" depath="<{$item.node_depth}>" class="clear_cat row" node_id="<{$item.node_id}>" parent_id="<{$item.parent_id}>">
            <div class='row-line' style="padding:0">
            <table cellpadding="0" cellspacing="0" border="0">
            <tr>
               <td width="18%" style="vertical-align:top">
             
      <div style="padding-left:<{($item.node_depth)*15}>px;text-align:left">
	<{if $tree_number<=500}>
                        <{if $item.has_children=='true'}>  <span class="handle-node" style='width:12px; height:12px;line-height:12px;overflow:hidden;display:inline-block;*margin-right:5px;cursor:pointer'>  <{img app='desktop' src="bundle/handle-hide.gif" alt=$___content="收起子分类"|t:'content'  title=$___content="收起子分类"|t:'content'  class="handle-hide" app='desktop'}>
                        <{img app='desktop' src="bundle/handle-show.gif" alt=$___content="收起子分类"|t:'content'  title=$___content="展开子分类"|t:'content'  class="handle-show" app='desktop'}> </span> 
                        <{/if}>
                        <{/if}>
                        
                        <a href="index.php?app=content&ctl=admin_node&act=edit&node_id=<{$item.node_id}>" target="dialog::{title:'<{t}>编辑<{/t}>'}"><{$item.node_name|t:'content'}></a></div>
          
                </td>
               <td width="12%" style="text-align:left; vertical-align:top">&nbsp;&nbsp;&nbsp;&nbsp; <span class="quiet"><{$item.node_pagename}></span></td>
			   <td width="8%" style="vertical-align:top">
			   	
			        <input class="_x_ipt" type="number" size="5"  name="ordernum[<{$item.node_id}>]" value="<{$item.ordernum|default:0}>" vtype="unsigned" style="display:none" /><b><{$item.ordernum|default:0}></b>    	 

			
			   </td>    
			    
			   <td width="45%" style="vertical-align:top">
				   	<div class="clearfix">
		 				   <!--<div class="span-auto">&nbsp;</div>
						   <div class="span-auto">&nbsp;</div>-->
						   <div class="span-auto">
						   	 <{assign var="node_id" value=$item.node_id}><span class="opt" onClick="new Dialog('index.php?app=content&ctl=admin_node&act=add&parent_id=<{$item.node_id}>', {title:'<{t}>添加子节点<{/t}>', height:470})"><{img src="bundle/addcate.gif" border="0" alt=$___content="添加子分类"|t:'content'  app='desktop'}>
							<{t}>添加子节点<{/t}>
							</span>
						   </div> 
						 <div class="span-auto">
                              <span class="opt"><a target="_blank" href="index.php?app=content&ctl=admin_article_detail&act=add&node_id=<{$item.node_id}>&type=1"><{img src="bundle/btn_add.gif" border="0" alt=$___content="在此节点下添加文章"|t:'content'  app='desktop'}><{t}>添加文章<{/t}></a></span>
						   </div>
						 <div class="span-auto">
                                <span class="opt" onClick="new Dialog('index.php?app=content&ctl=admin_node&act=edit&node_id=<{$item.node_id}>', {title:'<{t}>编辑<{/t}>'})"><{img src="bundle/editcate.gif" border="0" alt=$___content="编辑"|t:'content'   app='desktop'}><{t}>编辑<{/t}></span>
						   </div>
						 <div class="span-auto">
                               <span class="opt" onclick="deleteRow('index.php?app=content&ctl=admin_node&act=remove&node_id=<{$item.node_id}>',event)"><{img src="bundle/delecate.gif" border="0" alt=$___content="删除"|t:'content'  app='desktop'}><{t}>删除<{/t}></span>
						   </div>
						 <div class="span-auto">
                                <span class="opt" onclick='W.page("index.php?app=content&ctl=admin_article&act=index&filter[node_id]=<{$item.node_id}>&action=view&page=1")'><{img src="bundle/showcate.gif" border="0" alt=$___content="查看此节点下文章"|t:'content'  app='desktop'}><{t}>查看文章<{/t}></span>
						   </div>

						 <div class="span-auto last">
                              <span class="opt" onclick="window.open('<{$item.url}>')"><{img src="bundle/zoom_btn.gif" border="0" alt=$___content="跳转前台查看该"|t:'content'  app='desktop'}><{t}>浏览<{/t}></span>
						   </div> 
						 <div class="span-auto">
                         <{if $item.ifpub eq 'true'}>				
							<span class="opt" onClick="W.page('index.php?app=content&ctl=admin_node&act=publish&node_id=<{$item.node_id}>&pub=false')"><{img app=desktop src="bundle/visible.gif" }><{t}>已发布<{/t}></span>
							<{else}>
							<span class="opt" onClick="W.page('index.php?app=content&ctl=admin_node&act=publish&node_id=<{$item.node_id}>&pub=true')"><{img app=desktop src="bundle/un_visible.gif" }><{t}>已禁用<{/t}></span>
							<{/if}>
						   </div>
					</div>
			   </td>
                </tr>
                </table>
            </div>
        </div>
        <{/foreach}>
	</div>
    </div>

</form>
<script>

function deleteRow(act,event){
e=$(new Event(event).stop().target);
     var row=e.getParent('.row');
    
    if(confirm('<{t}>您确定要删除该节点？<{/t}>')){ 
        W.page(act,{
        method:'get',
        update:'messagebox',
        onComplete:function(re){
            
            if(re.contains('success')){row.remove();}
        
            }
        });
    }
}
<{if $tree_number<=500}>
void function(){   
   $E('#hideCat-handle').addEvent('click',function(){
    $ES('#node_tree .clear_cat').each(function(e){
        if(e.get('depath')>1){
            e.setStyles({'display':'none'});
        }
    });
    $ES('#node_tree .handle-hide').hide();
    $ES('#node_tree .handle-show').show();
  });
    $E('#showCat-handle').addEvent('click',function(){

        $ES('#node_tree .clear_cat').each(function(e){
            if(e.get('depath')>1){
                e.setStyles({'display':''});
            }
        });
        $ES('#node_tree .handle-hide').show();
    });

    $('node_tree').addEvent('click',function(e){
       
       if(!e.target.className.match(/handle-/i))return;
    

      var handle=$(e.stop().target);
			var eventRow=handle.getParent('.row');
			var visible=handle.hasClass('handle-show')?'':'none';	
				if(visible=='none'){	   
					 	 handle.hide().getNext().show();						  			 				   			  			   				    	
					}else{																   
					 	 handle.hide().getPrevious().show(); 						 
									    
					}	
			flode(eventRow,visible);

    });  

	$('edit-nodecatsort').addEvent('click',function(){
	     var _ctext = this.get('text');
	  	 if(_ctext.trim()=='<{t}>编辑排序<{/t}>'){
		  
		  $$('#node_tree input[vtype=unsigned]').each(function(item){
			   
			      item.style.cssText = "";
				  item.getNext().setStyle('display','none');
			
			});
			this.getElement('span span').set({'text':'<{t}>保存排序<{/t}>','styles':{color:'#ff3300'}}) 
		 }else{                                    
		   $('nodecatEditor').fireEvent('submit',{stop:function(){}}); 
		}
	     
	     
		
	
	});
   
	function flode(eventRow,visible){			
			var node_id=eventRow.get('node_id');
			var parent_id=eventRow.get('parent_id');	
			
			eventRow.getAllNext('div[parent_id='+node_id+']').each(function(row){								
				if(visible=='none'){						
					row.hide();
					var obj=row.getElements('.handle-node img');							
					if(obj.length>1){					
						flode(row,visible);	
					}											
				}else{						
					row.show();		
					var obj=row.getElements('.handle-node img');							
					if(obj.length>1){			   
						var vis=(obj[0].getStyle('display')=='none'?'none':'inline');			
						flode(row,vis);	
					}
				}	
						
			});
	}
}();
<{/if}>
var articlesEditFrame = (function(){

	/*
	 *  sign:{
		   1:保存并关闭,
		   2:保存当前不关闭，               
	 *    }       
	 */
	if(!$('catEditor'))return;
	var _form=$('catEditor'),_formActionURL=_form.get('action'); 
	subArticleForm = function (event,sign){  
	   var specOBJ='';	
	   var target={extraData:$('finder-tag').toQueryString()+'&'+specOBJ,onComplete:function(){}};
	 
	   switch (sign){
			case 1:
				$extend(target,{
					onComplete:function(){
						window.close();
					}}
				);
			break;
			case 2:
				$extend(target,{
					onRequest: function(){
						event.target.disabled = true;
					},
					onComplete:function(e){
						if(!JSON.decode(e).id){
							event.target.removeProperty('disabled');
							return;
						}
						var id = JSON.decode(e).id;
						if(id > 0){
							$('aEditor-Garticleid-input').value = JSON.decode(e).id;
						}
						event.target.disabled = false;
					}}
				);
			break;
			default:
			return;
	   }

		_form.store('target',target);
		_form.set('action',_formActionURL+'&but='+sign).fireEvent('submit',new Event(event));
	};
});

articlesEditFrame();

</script>
